package service;

import dao.EasyBuyUserDao;
import entity.Easybuy_user;
import utils.PageUtils;
import utils.SecurityUtils;

public class EasyBuyService {
	
	EasyBuyUserDao dao=new EasyBuyUserDao();
	
	public int existName(String loginName){
		return dao.existName(loginName);
	}
	
	public int regist(Easybuy_user user){
		String pwd=SecurityUtils.md5Hex(user.getPassword());
		user.setPassword(pwd);
		return dao.regist(user);
	}
	
	public Easybuy_user login(String name, String pwd){
		
		 Easybuy_user user = dao.login(name);
		if (user!=null) {
			if (user.getPassword().equals(SecurityUtils.md5Hex(pwd))) {
				return user;
			}
		}
		return null;
	}
	
	public PageUtils<Easybuy_user> UserList(int pageindex,int pageSize){
		int currpage=(pageindex-1)*pageSize;
		return dao.UserList(currpage,pageSize);
		
	}
	
	public Easybuy_user findById(int id){
		return dao.findById(id);
	}
	
	public int updateUser(Easybuy_user user){
		return dao.updateUser(user);
		
	}

}
